<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta content="en" name="language">
	<title>Magick Image File Format (version 1.0)</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link media="screen" href="docutils-articles.css" type="text/css" rel="stylesheet">

</head>

<body>

<div class="banner">
<img src="images/gm-107x76.png" alt="GraphicMagick logo" width="107" height="76" />
<span class="title">GraphicsMagick</span>
<form action="http://www.google.com/search">
  <input type="hidden" name="domains" value="www.graphicsmagick.org" />
  <input type="hidden" name="sitesearch" value="www.graphicsmagick.org" />
<span class="nowrap"><input type="text" name="q" size="25" maxlength="255" />&nbsp;<input type="submit" name="sa" value="Search" /></span>
</form>
</div>


<div class="navmenu">
<ul>
  <li><a href="index.html">Home</a></li>
  <li><a href="project.html">Project</a></li>
  <li><a href="download.html">Download</a></li>
  <li><a href="README.html">Install</a></li>
  <li><a href="Hg.html">Source</a></li>
  <li><a href="NEWS.html">News</a> </li>
  <li><a href="utilities.html">Utilities</a></li>
  <li><a href="programming.html">Programming</a></li>
  <li><a href="reference.html">Reference</a></li>
</ul>
</div>

<main id="magick-image-file-format-version-1-0">
<h1 class="title">Magick Image File Format (version 1.0)</h1>
<!-- -*- mode: rst -*- -->
<!-- This text is in reStucturedText format, so it may look a bit odd. -->
<!-- See http://docutils.sourceforge.net/rst.html for details. -->
<p>Magick Image File Format (MIFF) is a platform-independent format for
storing bitmap images. MIFF was originally invented by John Cristy for
ImageMagick, but is also a native format of GraphicsMagick. It is
useful as an efficient lossless working file format which assures that
all of the image attributes used by ImageMagick and GraphicsMagick are
preserved. Several lossless compression algorithms are available in
order to save space.</p>
<section id="description">
<h1>Description</h1>
<p>A MIFF image file consist of two sections. The first section is a header
composed of keywords describing the image in text form. The next section
is the binary image data. The header is separated from the image data by
a : character immediately followed by a ctrl-Z.</p>
<p>The MIFF header is composed entirely of LATIN-1 characters. The fields in
the header are keyword and value combination in the keyword=value format,
with each keyword and value separated by an equal sign (=). Each
keyword=value combination is delimited by at least one control or
whitespace character. Comments may appear in the header section and are
always delimited by braces. The MIFF header always ends with a colon (:)
character, followed by a ctrl-Z character. It is also common to precede
the colon with a formfeed and a newline character. The formfeed prevents
the listing of binary data when using more(1) under Unix where the ctrl-Z
has the same effect with the type command on the Win32 command line.</p>
<p>It is required that the 'id' keyword be present with the value
'ImageMagick' (id=ImageMagick) and be the first keyword listed in the
MIFF header.  Files not starting with this keyword/value may be
rejected.  The 'version' keyword must always be emitted for all new
files with the value '1.0' (version=1.0).</p>
<p>The MIFF header supports arbitrary LATIN-1 keyword strings.  Some
keyword strings have special interpretation while others are merely
stored as image attributes.  The following is a list of keyword=value
combinations with special interpretation that may be found in a MIFF
file:</p>
<p>background-color=color</p>
<p>border-color=color</p>
<p>matte-color=color</p>
<blockquote>
<p>these optional keywords reflects the image background, border, and
matte colors respectively. A color can be a name (e.g. white) or a hex
value (e.g. #ccc).</p>
</blockquote>
<p>class=DirectClass</p>
<p>class=PseudoClass</p>
<blockquote>
<p>the type of binary image data stored in the MIFF file. If this keyword
is not present, DirectClass image data is assumed.</p>
</blockquote>
<p>colors=value</p>
<blockquote>
<p>the number of colors in a DirectClass image. For a PseudoClass image,
this keyword specifies the size of the colormap. If this keyword is not
present in the header, and the image is PseudoClass, a linear 256 color
grayscale colormap is used with the image data. The maximum number of
colormap entries is 65535.</p>
</blockquote>
<p>columns=value</p>
<blockquote>
<p>the width of the image in pixels. This is a required keyword and has no
default.</p>
</blockquote>
<p>colorspace=RGB</p>
<p>colorspace=CMYK</p>
<blockquote>
<p>the colorspace of the pixel data. The default is RGB.</p>
</blockquote>
<p>comment={text}</p>
<blockquote>
<p>comment text.  Note that extremely old MIFF files used a different
means to indicate comment text.</p>
</blockquote>
<p>compression=BZip</p>
<p>compression=None</p>
<p>compression=RLE</p>
<p>compression=Zip</p>
<blockquote>
<p>the type of algorithm used to compress the image data. If this keyword
is not present, the image data is assumed to be uncompressed.</p>
</blockquote>
<p>delay &lt;1/100ths of a second&gt;</p>
<blockquote>
<p>the interframe delay in an image sequence. The maximum delay is 65535.</p>
</blockquote>
<p>depth=8</p>
<p>depth=16</p>
<p>depth=32</p>
<blockquote>
<p>depth of a single color value representing values from 0 to 255
(depth 8), 65535 (depth 16), or 4294967295 (depth 32). If this
keyword is absent, a depth of 8 is assumed.  Depth values of 1 to 32
are accepted, with the storage depth being rounded up to 8, 16,
or 32.</p>
</blockquote>
<p>dispose value</p>
<blockquote>
<p>GIF disposal method. Here are the valid methods:</p>
<blockquote>
<table>
<colgroup>
<col style="width: 19%" />
<col style="width: 81%" />
</colgroup>
<tbody>
<tr><td><p>Disposal</p></td>
<td><p>Description</p></td>
</tr>
<tr><td><p>0</p></td>
<td><p>No disposal specified.</p></td>
</tr>
<tr><td><p>1</p></td>
<td><p>Do not dispose between frames.</p></td>
</tr>
<tr><td><p>2</p></td>
<td><p>Overwrite frame with background color from
header.</p></td>
</tr>
<tr><td><p>3</p></td>
<td><p>Overwrite with previous frame.</p></td>
</tr>
</tbody>
</table>
</blockquote>
</blockquote>
<p>gamma=value</p>
<blockquote>
<p>gamma of the image. If it is not specified, a gamma value of
.45454545 (linear-intensity gamma &quot;2.2&quot; as used by NTSC, sRGB, and
Rec.709) is assumed.  A gamma value of 1.0 indicates linear-light.</p>
</blockquote>
<p>id=ImageMagick</p>
<blockquote>
<p>identify the file as a MIFF-format image file. This keyword is required
and has no default. Although this keyword can appear anywhere in the
header, it should start as the first keyword of the header in column 1.
This will allow programs like file(1) to easily identify the file as
MIFF.</p>
</blockquote>
<p>iterations value</p>
<blockquote>
<p>the number of times an image sequence loops before stopping.</p>
</blockquote>
<p>label={value}</p>
<blockquote>
<p>this optional keyword defines a short title or caption for the image.
If any whitespace appears in the label, it must be enclosed within
double quotes.</p>
</blockquote>
<p>matte=True</p>
<p>matte=False</p>
<blockquote>
<p>specifies whether a DirectClass image has matte data. Matte data is
generally useful for image compositing. This keyword has no meaning for
pseudocolor images.</p>
</blockquote>
<p>montage=&lt;width&gt;x&lt;height&gt;{+-}&lt;xoffset&gt;{+-}&lt;yoffset&gt;</p>
<blockquote>
<p>size and location of the individual tiles of a composite image. See
X(1) for details about the geometry specification. Use this keyword
when the image is a composite of a number of different tiles. A tile
consists of an image and optionally a border and a label. &lt; width&gt; is
the size in pixels of each individual tile in the horizontal direction
and &lt;height&gt; is the size in the vertical direction. Each tile must have
an equal number of pixels in width and equal in height. However, the
width can differ from the height. &lt;xoffset&gt; is the offset in number of
pixels from the vertical edge of the composite image where the first
tile of a row begins and &lt;yoffset&gt; is the offset from the horizontal
edge where the first tile of a column begins. If this keyword is
specified, a directory of tile names must follow the image header. The
format of the directory is explained below.</p>
</blockquote>
<p>page=&lt;width&gt;x&lt;height&gt;{+-}&lt;xoffset&gt;{+-}&lt;yoffset&gt;</p>
<blockquote>
<p>preferred size and location of an image canvas.</p>
</blockquote>
<p>profile-icc=value</p>
<blockquote>
<p>the number of bytes in the International Color Consortium color
profile. The profile is defined by the ICC profile specification.</p>
</blockquote>
<p>profile-iptc=value</p>
<blockquote>
<p>the number of bytes in the IPTC Newsphoto profile. The profile is
defined by the IPTC specification.</p>
</blockquote>
<p>profile-name=value</p>
<blockquote>
<p>the number of bytes in the generic profile name where name identifies
the profile. Name is substituted with any LATIN-1 string to form a
unique generic profile identifier.</p>
</blockquote>
<p>profile:name=value</p>
<blockquote>
<p>the number of bytes in the generic profile name where name identifies
the profile. Name is substituted with any LATIN-1 string to form a
unique generic profile identifier.</p>
</blockquote>
<p>red-primary=x,y</p>
<p>green-primary=x,y</p>
<p>blue-primary=x,y</p>
<p>white-point=x,y</p>
<blockquote>
<p>these optional keywords reflect the chromaticity primaries and white point.</p>
</blockquote>
<p>rendering-intent=saturation</p>
<p>rendering-intent=perceptual</p>
<p>rendering-intent=absolute</p>
<p>rendering-intent=relative</p>
<blockquote>
<p>Rendering intent is the CSS-1 property that has been defined by the
International Color Consortium.</p>
</blockquote>
<p>resolution=&lt;x-resolution&gt;x&lt;y-resolution&gt;</p>
<blockquote>
<p>vertical and horizontal resolution of the image. See units for the
specific resolution units (e.g. pixels per inch).</p>
</blockquote>
<p>rows=value</p>
<blockquote>
<p>the height of the image in pixels. This is a required keyword and has
no default.</p>
</blockquote>
<p>orientation=value</p>
<blockquote>
<p>specifies the orientation of the image as an attribute (does not
effect pixel storage).  Supported values are TopLeft, TopRight,
BottomRight, BottomLeft, LeftTop, RightTop, RightBottom, LeftBottom
as specified by the TIFF and EXIF standards.</p>
</blockquote>
<p>scene=value</p>
<blockquote>
<p>the sequence number for this MIFF image file. This optional keyword is
used when a MIFF image file is one in a sequence of files used in an
animation.</p>
</blockquote>
<p>signature=value</p>
<blockquote>
<p>this optional keyword contains a string that uniquely identifies the
image pixel contents. NIST's SHA-256 message digest algorithm is
recommended.</p>
</blockquote>
<p>units=pixels-per-inch</p>
<p>units=pixels-per-centimeter</p>
<blockquote>
<p>image resolution units.</p>
</blockquote>
<p>version=1.0</p>
<blockquote>
<p>Identifies the MIFF version used, which is 1.0 for the purpose of
this specification.  If version is omitted, then certain MIFF
features (e.g. compressed rows) are assumed to be encoded using a
defunct MIFF format.</p>
</blockquote>
<p>Other key value pairs are permitted. If a value contains whitespace it must be
enclosed with braces as illustrated here:</p>
<pre class="literal-block">id=ImageMagick  version=1.0
class=PseudoClass colors=256
compression=RLE
columns=1280 rows=1024
scene=1
signature=d79e1c308aa5bbcdeea8ed63df412da9
copyright={Copyright (c) 2000 Mortimer Snerd}
&lt;FF&gt;
:</pre>
<p>Note that keyword=value combinations may be separated by newlines or
spaces and may occur in any order within the header. Comments (within
braces) may appear anywhere before the colon.</p>
<p>The elements shown in the following table may appear after the header and
before the image data. These elements appear in the order described in
the following table if the keyword indicates that they exist.</p>
<table>
<colgroup>
<col style="width: 21%" />
<col style="width: 21%" />
<col style="width: 57%" />
</colgroup>
<tbody>
<tr><td><p>Element</p></td>
<td><p>Keyword</p></td>
<td><p>Description</p></td>
</tr>
<tr><td><p>Image
directory</p></td>
<td><p>montage</p></td>
<td><p>The directory consists of a name for each
tile of the composite image separated by
a newline character. The list is
terminated with a NULL character.</p></td>
</tr>
<tr><td><p>ICC Profile</p></td>
<td><p>profile-icc</p></td>
<td><p>Binary color profile.</p></td>
</tr>
<tr><td><p>IPTC Profile</p></td>
<td><p>profile-iptc</p></td>
<td><p>Binary IPTC Newsphoto profile.</p></td>
</tr>
<tr><td><p>Generic
Profiles</p></td>
<td><p>profile-&lt;name&gt;</p></td>
<td><p>Binary generic profile. Multiple named
generic profiles may exist.</p></td>
</tr>
</tbody>
</table>
<p>Next comes the binary image data itself. How the image data is formatted
depends upon the class of the image as specified (or not specified) by
the value of the class keyword in the header. All numeric values in the
binary section are written with the most significant bytes occurring first
(big-endian ordering).</p>
<p>DirectClass images (class=DirectClass) are continuous-tone, images stored
as RGB (red, green, blue), RGBA (red, green, blue, alpha), CMYK (cyan,
yellow, magenta, black), and CMYKA (cyan, yellow, magenta, black, alpha)
intensity values as defined by the colorspace and matte keywords. The
size of each intensity value depends on the depth of the image. The
depth, number of bytes, and numeric range of each value are shown in the
following table:</p>
<blockquote>
<table>
<colgroup>
<col style="width: 21%" />
<col style="width: 41%" />
<col style="width: 38%" />
</colgroup>
<tbody>
<tr><td><p>Depth</p></td>
<td><p>Bytes Per
Value</p></td>
<td><p>Value Range</p></td>
</tr>
<tr><td><p>8</p></td>
<td><p>1</p></td>
<td><p>0..255</p></td>
</tr>
<tr><td><p>16</p></td>
<td><p>2</p></td>
<td><p>0..65535</p></td>
</tr>
<tr><td><p>32</p></td>
<td><p>4</p></td>
<td><p>0..4294967295</p></td>
</tr>
</tbody>
</table>
</blockquote>
<p>The alpha value (if it occurs) represents the degree of pixel opacity
(zero is totally transparent).</p>
<p>PseudoClass images (class=PseudoClass) are colormapped RGB images. The
colormap is stored as a series of red, green, and blue pixel values. The
size of each colormap value depends on the image depth, as shown in the
following table:</p>
<blockquote>
<table>
<colgroup>
<col style="width: 19%" />
<col style="width: 22%" />
<col style="width: 31%" />
<col style="width: 28%" />
</colgroup>
<tbody>
<tr><td><p>Depth</p></td>
<td><p>Bytes Per
Value</p></td>
<td><p>Value Range</p></td>
<td><p>Bytes Per
Colormap Entry</p></td>
</tr>
<tr><td><p>8</p></td>
<td><p>1</p></td>
<td><p>0..255</p></td>
<td><p>3</p></td>
</tr>
<tr><td><p>16</p></td>
<td><p>2</p></td>
<td><p>0..65535</p></td>
<td><p>6</p></td>
</tr>
<tr><td><p>32</p></td>
<td><p>4</p></td>
<td><p>0..4294967295</p></td>
<td><p>12</p></td>
</tr>
</tbody>
</table>
</blockquote>
<p>The number of colormap entries is defined by the colors keyword. The
colormap data occurs immediately following the header (or image directory
if the montage keyword is in the header). Immediately following the
colormap data is the PseudoClass image data. PseudoClass image data is an
array of index values into the color map. The number of bytes comprising
the index value depends on the number of colors in the image. The
following table shows the number of bytes in each colormap index as
determined by the colors keyword:</p>
<blockquote>
<table>
<colgroup>
<col style="width: 31%" />
<col style="width: 31%" />
<col style="width: 38%" />
</colgroup>
<tbody>
<tr><td><p>Colors</p></td>
<td><p>Bytes Per
Index</p></td>
<td><p>Index Range</p></td>
</tr>
<tr><td><p>&lt;=256</p></td>
<td><p>1</p></td>
<td><p>0..255</p></td>
</tr>
<tr><td><p>&lt;=65535</p></td>
<td><p>2</p></td>
<td><p>0..65535</p></td>
</tr>
<tr><td><p>&lt;=4294967295</p></td>
<td><p>4</p></td>
<td><p>0..4294967295</p></td>
</tr>
</tbody>
</table>
</blockquote>
<p>If matte is true, each colormap index is immediately followed by an
equally-sized alpha value. The alpha value represents the degree of pixel
opacity (zero is totally transparent).</p>
<p>The image data in a MIFF file may be uncompressed, runlength encoded,
Zip compressed, or BZip compressed. The compression keyword in the
header defines how the image data is compressed. Uncompressed pixels
are stored one scanline at a time in row order. Runlength encoded
compression counts runs of identical adjacent pixels and stores the
pixels followed by a length byte (the number of identical pixels minus
1). Zip and BZip compression for version 1.0 compresses each row of an
image and precedes the compressed row with the length of compressed
pixel bytes as a 32-bit unsigned value in most significant byte first
order. If the version tag is not present (indicating a virtually
unused legacy format) then Zip and BZip omit this length value and the
reader must incrementally decode each row and restart compression at
the point where decoding completed for the previous row.</p>
<p>Note that compression in MIFF is scanline-based without any
specialized pre-processing as is found in the PNG and TIFF file
formats.  As a result, available compression levels are likely to be
less than some other file formats given the same compression algorithm.</p>
<p>MIFF files may contain more than one image. Simply concatenate each
individual image (composed of a header and image data) into one file.</p>
</section>
<section id="authors">
<h1>Authors</h1>
<p>John Cristy, <a class="reference external" href="mailto:magick-users&#37;&#52;&#48;imagemagick&#46;org">magick-users<span>&#64;</span>imagemagick<span>&#46;</span>org</a> ImageMagick Studio LLC.</p>
<p>Maintained since 2002 by Bob Friesenhahn, GraphicsMagick Group.</p>
</section>
</main>


<hr class="docutils">
<div class="document">
    <p><a href="Copyright.html">Copyright</a> © GraphicsMagick Group 2002-2025<!--SPONSOR_LOGO--></p>
</div>

</main>
</body>
</html>
